home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0147_Send Tabs when Enter is pressed.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-08-30  |  2.2 KB  |  106 lines

  1. {
  2. Sorry you must use the sendmessage API to do this.
  3. use the winsight32 to spy this message !.
  4. you can find in compsit.pas a new component witch send a TAB key
  5. when you press ENTER
  6.  
  7. Best regards
  8.  
  9. Pierre
  10.  
  11. pmarmet@mnet.fr
  12. }
  13.  
  14. unit compsit;
  15. //*******************************************
  16. // Classe TDBedite
  17. // avec gestion de la touche ENTREE
  18. // (c)SIT 8/5/1996 MARMET Pierre
  19. //*******************************************
  20.  
  21.  
  22. interface
  23.  
  24. uses
  25.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  26.   StdCtrls,DBCtrls;
  27.  
  28. type
  29.   TDBEdite = class(TDBEdit)
  30.  
  31.   private
  32.   Tentree: integer;
  33.   varia: boolean;
  34.   oldvalue: string;            {memorise l'ancienne valeur du composant}
  35.  
  36.   function getpierre: integer;
  37.   procedure setpierre (param1: integer);
  38.   procedure WndProc(var Message: TMessage) ;override;
  39.     { DΘclarations privΘes }
  40.   protected
  41.     { DΘclarations protΘgΘes }
  42.  
  43.  
  44.   public
  45.   constructor Create(AOwner: TComponent); override;
  46.  
  47.    { DΘclarations publiques }
  48.   published
  49.   //property ENTREE: Boolean read Getpierre write Setpierre default True;
  50.   / property ENTERKey: integer read getpierre write setpierre default 1;
  51.   property DoEnterKey: boolean read varia write varia;
  52.     { DΘclarations publiΘes }
  53.   end;
  54.  
  55.  
  56. procedure Register;
  57.  
  58. implementation
  59.  
  60. procedure Register;
  61. begin
  62.   RegisterComponents('Exemples', [TDBEdite]);
  63. end;
  64.  
  65. Constructor TDBEdite.Create(AOwner: TComponent);
  66. begin
  67.      inherited Create(AOwner);
  68. //     ENTERKey := 1;
  69.      varia:=True;
  70. end;
  71.  
  72. function TDBEdite.getpierre: integer;
  73. begin
  74.      result := Tentree;
  75. end;
  76.  
  77. procedure TDBEdite.setpierre(param1: integer);
  78. begin
  79.      if param1 > 1 then param1:=1;
  80.      Tentree:=param1;
  81. end;
  82.  
  83.  
  84.  
  85. procedure TDBEdite.WndProc(var Message: TMessage);
  86. begin
  87.  
  88.   if (message.msg = WM_CHAR) then
  89.  
  90.      begin
  91.  
  92.      // La touche ENTREE provoque une tabulation sur le controle
  93.      if (message.WParam = 13) and ( varia = True ) then
  94.           begin
  95.               sendmessage(self.Handle,WM_USER+$B900,9,$F0001);
  96.               exit;
  97.           end;
  98.      end;
  99.  
  100.   inherited WndProc(Message);        { rΘpartition normale }
  101. end;
  102.  
  103.  
  104.  
  105. end.
  106.